<?php
namespace frontend\controllers;

use yii\web\Controller;
use Yii;
use yii\web\Response;

class APIController extends Controller
{
    //json方法
    public function json($data, $code = 1001, $msg = '加载成功') {
    	Yii::$app->response->format = Response::FORMAT_JSON;
    	echo \yii\helpers\Json::encode(['code' => $code, 'msg' => $msg, 'data' => $data]);
    }
}
